* Mark Nieman and Maxwell Allamong
* School of Thought - Data Analysis for Appendix
* November 7, 2022
version 14
  quietly log
  local logon = r(status)
 if "`logon'" == "on" {
	log close
 }
log using NiemanAllamong_SoT_Appendix_stata.log, text replace

* need to download -etregress- utility to estimate models

* Load data and set seed
insheet using SoT_LEAD.csv, clear
set seed 332

* Transform variables from text to numeric
destring changetradeliberal changelji changekaopen changehrscore changelibdem euroedu noneuroedu rgdppc oil xconstv uk_col us_ally ethfrac pop tenure euroedu noneuroedu angloameredu boarding startlji startkaopen starthrscore startlibdem starttradeliberal, replace force

* Log transform on two variables
gen log_rgdppc = ln(rgdppc)
gen log_pop = ln(pop)

* Estimate four continuous dependent variables
etregress changelji euroedu noneuroedu log_rgdppc oil  uk_col us_ally ethfrac log_pop tenure startlji, 	treat(angloameredu = boarding log_rgdppc oil uk_col us_ally ethfrac log_pop tenure startlji) vce(r) 
	estimates store law
	
etregress changekaopen euroedu noneuroedu log_rgdppc oil xconstv uk_col us_ally ethfrac log_pop tenure startkaopen, treat(angloameredu = boarding log_rgdppc oil xconstv uk_col us_ally ethfrac log_pop tenure startkaopen) vce(r) 
	estimates store ka
	
etregress changehrscore euroedu noneuroedu log_rgdppc oil xconstv uk_col us_ally ethfrac log_pop tenure starthrscore, treat(angloameredu = boarding log_rgdppc oil xconstv uk_col us_ally ethfrac log_pop tenure starthrscore) vce(r) 
	estimates store hr
	
etregress changelibdem euroedu noneuroedu log_rgdppc oil uk_col us_ally ethfrac log_pop tenure startlibdem, treat(angloameredu = boarding log_rgdppc oil uk_col us_ally ethfrac log_pop tenure startlibdem) vce(r)
	estimates store dem

* Subset data to non-liberal trade subsample and estimate
keep if starttradeliberal==0		
etregress changetradeliberal euroedu noneuroedu log_rgdppc oil xconstv uk_col us_ally ethfrac log_pop tenure, treat(angloameredu = boarding log_rgdppc oil xconstv uk_col us_ally ethfrac log_pop tenure) vce(r)	
estimates store trade

* Table A.10: Educational Models and Political Outcomes, Instrumental Variables
estout trade law ka hr dem, stats(N) cells(b(fmt(3) star) se(par)) modelwidth(8) starlevels(+ 0.2 * 0.1 ** 0.05 ) legend varwidth(15) style(tex) replace
	

